﻿//Copyrigh (C) 2021 上海东欣软件工程有限公司 版权所有。
//<author>邢耀光</author>
//<data>2021.1.31</data>

using Core;
using System.Collections.Generic;
using System.Data;

namespace Dal
{
    /// <summary>
    /// 部门操作类接口
    /// </summary>
    public interface IDepartmentDao
    {
        /// <summary>
        /// 添加部门
        /// </summary>
        /// <param name="department">部门信息</param>
        /// <param name="connString">数据库连接字符串</param>
        /// <returns>影响行数，1成功，0失败</returns>
        int InsertDepartment(Department department, string connString);

        /// <summary>
        /// 修改部门
        /// </summary>
        /// <param name="department">部门信息</param
        /// <param name="connString">数据库连接字符串</param>
        /// <returns>影响行数，1成功，0失败</returns>
        int UpdateDepartment(Department department, string connString);

        /// <summary>
        /// 删除部门
        /// </summary>
        /// <param name="id">部门id</param>
        /// <param name="connString">数据库连接字符串</param>
        /// <returns>影响行数，1成功，0失败</returns>
        int DeleteDepartment(long id, string connString);

        /// <summary>
        /// 模糊查询部门
        /// </summary>
        /// <param name="args">部门查询参数信息</param>
        /// <param name="connString">数据库连接字符串</param>
        /// <returns>查询结果集</returns>
        List<Department> QueryDepartment(Department args, string connString);

        /// <summary>
        /// 精确查询部门
        /// </summary>
        /// <param name="args">部门查询参数信息</param>
        /// <param name="connString">数据库连接字符串</param>
        /// <returns>查询结果集</returns>
        List<Department> ExactQueryDepartment(Department args, string connString);

        /// <summary>
        /// 执行储存过程获取当前部门所有父级列表
        /// </summary>
        /// <param name="connString">数据库连接字符串</param>
        /// <param name="departmentID">当前部门ID</param>
        /// <returns>查询结果集</returns>
        DataTable GetAncestorDepartments(string connString, int departmentID);

        /// <summary>
        /// 执行储存过程获取当前部门所有子级级列表
        /// </summary>
        /// <param name="connString">数据库连接字符串</param>
        /// <param name="departmentID">当前部门ID</param>
        /// <returns>查询结果集</returns>
        DataTable GetDescendantDepartments(string connString, int departmentID);
        /// <summary>
        /// 根据部门名称判断是否存在
        /// </summary>
        /// <param name="connString">数据库连接字符串</param>
        /// <param name="departmentName">部门名称</param>
        /// <returns>是否存在</returns>
        bool ExistDepartment(string connString, string departmentName);

        /// <summary>
        /// 判断当前部门下的部门名称是否存在
        /// </summary>
        /// <param name="connString">数据库连接字符串</param>
        /// <param name="id">当前部门id</param>
        /// <param name="departmentName">部门名称</param>
        /// <returns>是否存在</returns>
        bool ExistDepartment(string connString, int id, string departmentName);

        /// <summary>
        /// 根据部门id判断是否存在子级部门
        /// </summary>
        /// <param name="connString">数据库连接字符串</param>
        /// <param name="departmentID">部门ID</param>
        /// <returns>是否存在</returns>
        bool ExistDepartmentChildren(string connString, int departmentID);

        /// <summary>
        /// 根据部门id判断当前部门是否是根部门
        /// </summary>
        /// <param name="connString">数据库连接字符串</param>
        /// <param name="departmentID">部门ID</param>
        /// <returns>是否存在</returns>
        bool DepartmentIsRoot(string connString, int departmentID);

        /// <summary>
        /// 根据当前部门id获得下一级部门
        /// </summary>
        /// <param name="connString">数据库连接字符串</param>
        /// <param name="departmentID">部门ID</param>
        /// <returns>是否存在</returns>
        List<Department> GetDepartmentChildrens(string connString, int departmentID);

        /// <summary>
        /// 根据当前部门父id获得上一级部门
        /// </summary>
        /// <param name="connString">数据库连接字符串</param>
        /// <param name="departmentParentID">部门父ID</param>
        /// <returns>是否存在</returns>
        List<Department> GetDepartmentParents(string connString, int departmentParentID);
    }
}
